﻿using System;
using System.Collections;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public class WarehouseReport : BaseReport
    {
        string strCompany = "HLT";
        string strExcelFile = "";
        public WarehouseReport()
            : base()
        {
        }
        public WarehouseReport(Dictionary<string, object> dicParamater)
            : base(dicParamater)
        { 
            strCompany = dicParamater["Company"].ToString().Trim();
            strExcelFile = dicParamater["ExcelFile"].ToString().Trim();
            
           
        }
        private void FINISH_INVENTORY_SUMMARY_COLUMNS()
        {
            columns.Add("WADART"); columns.Add("WBBEINDAT"); columns.Add("WBBDPART"); columns.Add("UNCHECKEDQTY");
            columns.Add("UNCHECKEDMTR"); columns.Add("CHECKEDQTY"); columns.Add("CHECKEDMTR"); columns.Add("OTHERQTY");
            columns.Add("OTHERMTR");
        }

        public void FINISH_INVENTORY_SUMMARY_TO_EXCEL(string fileType)
        {  
            Queue CellQueue = new Queue();
            FINISH_INVENTORY_SUMMARY_COLUMNS();
            string filename = "";
            string sheetName = "";
            string Standard = "Sales_Finish_Stock";
            strExcelFile = @"HLT\HLTSummaryReport.xls";
            string filePath = @"C:\intex.w\Report\" + strExcelFile;
            exAgent.Open(filePath);
            exAgent.Company = "";
            exAgent.strExcelFile = strExcelFile;
            string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            filename = @"Sales\成品结存报表" + filedate + ".xls";
            sheetName = DateTime.Now.ToShortTimeString().Replace(@":","");
            exAgent.CreateNewSheet(filename, Standard, sheetName);
            FillInData(columns, dsSource.Tables["FINISH_INVENTORY_SUMMARY"]); 
            if (exAgent != null)
            {
                exAgent.Save();
                exAgent.Close();
            }
        }
        private void YARN_INVENTORY_COLUMNS()
        {
            columns.Add("CODE"); columns.Add("GLLB"); columns.Add("ART"); columns.Add("VAR"); columns.Add("BEZ");
            columns.Add("SUPPLIER"); columns.Add("SUPPLIERBATCH"); columns.Add("LOT"); columns.Add("WEI");
            
        }
        
        public void YARN_INVENTORY_TO_EXCEL(string fileType)
        {
            Queue CellQueue = new Queue();
            YARN_INVENTORY_COLUMNS();
            string filename = "";
            string sheetName = "";
            string Standard = "Warehouse_Yarn_Stock";
            strExcelFile = @"HLT\HLTSummaryReport.xls";
            string filePath = @"C:\intex.w\Report\" + strExcelFile;
            exAgent.Open(filePath);
            exAgent.Company = "";
            exAgent.strExcelFile = strExcelFile;
            string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            filename = @"Warehouse\纱线库存报表" + filedate + ".xls";
            sheetName = DateTime.Now.ToShortTimeString().Replace(@":", "");
            exAgent.CreateNewSheet(filename, Standard, sheetName);
            FillInData(columns, dsSource.Tables["YARN_INVENTORY"]);
            if (exAgent != null)
            {
                exAgent.Save();
                exAgent.Close();
            }
        }

        private void Piece_Inspection_COLUMNS()
        {
            columns.Add("WBBDPART"); columns.Add("CARDNO"); columns.Add("WBBSTKNR"); columns.Add("WBFVERSION");
            columns.Add("WBFKNEUDAT"); columns.Add("WBFKWARSCH"); columns.Add("WBFKSART"); columns.Add("YARDQTY");
            columns.Add("WBFFSCHL"); columns.Add("DES"); columns.Add("LENFROM"); columns.Add("LENUPTO"); columns.Add("WIDTHFROM");
            columns.Add("WIDTHUPTO"); columns.Add("REMARK"); 
        }

        public void Piece_Inspection_TO_EXCEL(string fileType)
         {
             Queue CellQueue = new Queue();
             Piece_Inspection_COLUMNS();
             string filename = "";
             string sheetName = "";
             string Standard = "Warehouse_Piece_Inspection";
             strExcelFile = @"HLT\HLTSummaryReport.xls";
             string filePath = @"C:\intex.w\Report\" + strExcelFile;
             exAgent.Open(filePath);
             exAgent.Company = "";
             exAgent.strExcelFile = strExcelFile;
             string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
             filename = @"Warehouse\布卷检验报告" + filedate + ".xls";
             sheetName = DateTime.Now.ToShortTimeString().Replace(@":", "");
             exAgent.CreateNewSheet(filename, Standard, sheetName);
             FillInData(columns, dsSource.Tables["PIECE_INSPECTION"]);
             if (exAgent != null)
             {
                 exAgent.Save();
                 exAgent.Close();
             }
         }
    }

}
